package com.twu.biblioteca;

import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * User: dbelsey
 * Date: 31/01/13
 * Time: 15:09
 */
public abstract class IOHandler {

    protected InputStream userInputStream;
    protected PrintStream appOutputStream;
    protected Scanner inputScanner;


    public int getInputNumber() throws NumberFormatException{
        if(inputScanner.hasNextInt()){
            return inputScanner.nextInt();
        }
        else {
            inputScanner.next();
            throw new NumberFormatException();
        }
    }

    public String getInputString(){
            return inputScanner.next();

 //       else {
 //           inputScanner.next();
 //           throw new NumberFormatException();
 //       }
    }

    public void sendOutput(String outputString) {
        appOutputStream.println(outputString);
    }

    public void sendOutputPrint(String outputString) {
        appOutputStream.print(outputString);
    }
}